<?php



require_once 'Zend/Search/Lucene/Search/Highlighter/Interface.php';

class Zend_Search_Lucene_Search_Highlighter_Default implements Zend_Search_Lucene_Search_Highlighter_Interface
{
    
    protected $_highlightColors = array('#66ffff', '#ff66ff', '#ffff66',
                                        '#ff8888', '#88ff88', '#8888ff',
                                        '#88dddd', '#dd88dd', '#dddd88',
                                        '#aaddff', '#aaffdd', '#ddaaff',
                                        '#ddffaa', '#ffaadd', '#ffddaa');

    
    protected $_currentColorIndex = 0;

    
    protected $_doc;

    
    public function setDocument(Zend_Search_Lucene_Document_Html $document)
    {
        $this->_doc = $document;
    }

    
    public function getDocument()
    {
        return $this->_doc;
    }

    
    public function highlight($words)
    {
        $color = $this->_highlightColors[$this->_currentColorIndex];
        $this->_currentColorIndex = ($this->_currentColorIndex + 1) % count($this->_highlightColors);

        $this->_doc->highlight($words, $color);
    }

}
